<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Page_Template extends Controller_Template {

	//Template layout for website
	public $template = 'template/page_template';
	
	// Page title of each page, this variable is overridden in each controller
	protected $page_title = 'Project Manager Web';
	
	// Stylesheets for page, this variable is modified in each controller: add more stylesheets (if needed)
	protected $styles = array();
	
	// Common script for page
	protected $scripts = array();
	// Config variables
	protected $config = array();
	
	// Page content for each page, this varialbe is overidden in each controller
	protected $primary_content; // main
	
	//Page single collum
	protected $single_cotent;
	protected $control_navigation;
	
	// Page content for each page, this varialbe is overidden in each controller
	protected $secondary_content; // main + sidebar
	
	protected  $top_header = '';
	
	private $side_view = array();
	public function add_sidebar($functions)
	{
		$this->side_view = $functions;
		//foreach ($functions as $function)
		//	$this->side_view[] = //array('controller' => $function['controller'], 'name' => $function['name'], 'child' => $function['child']);
	}
	public function add_sidebar_view($views)
	{
		$this->side_view[] = $views;
	}
	public function before()
	{
		$this->styles = array(
			"./public/assets/default.css" => 'all',
			"./public/assets/jquery-ui-1.8.16.custom.css" => 'screen',
			"./public/assets/jquery-ui-timepicker-addon.css" => 'screen',
			//"./public/assets/elrte.min.css" => 'screen',
		);
		// Common script for page
		$this->scripts = array(
		);
		
		$this->top_header = View::factory('/header/user_optimize');
		$this->secondary_content = View::factory('partials/sidebar');
		$this->secondary_content->bind('side_view', $this->side_view);
		parent::before();
	}
	
	public function after()
	{
		if ($this->auto_render)
		{
			$this->template->primary_content 	= $this->primary_content;
			$this->template->secondary_content	= $this->secondary_content;

			$this->template->control_navigation	= $this->control_navigation;
			$this->template->single_content		= $this->single_cotent;
			
			$this->template->top_header			= $this->top_header;
			$this->template->page_title			= $this->page_title;
			$this->template->styles 		 	= $this->styles;
		}
		parent::after();
	}
} 